package inbound.receiving.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class ReceiptHeaderDO
	{
		public var INTERNAL_RECEIPT_NUM:Number = 0;
		public var WAREHOUSE:String = "";
		public var COMPANY:String = "";
		public var RECEIPT_ID:String = "";
		public var RECEIPT_TYPE:String = "";
		public var CLOSE_DATE:String = DateManager.GetTodayString();
		public var PRIORITY:Number = 10;
		public var LEADING_STS:Number = 100;
		public var TRAILING_STS:Number = 100;
		public var ERP_ORDER_ID:String = "";
		public var SHIP_FROM:String = "";
		public var SHIP_FROM_ADDRESS1:String = "";
		public var SHIP_FROM_ADDRESS2:String = "";
		public var SHIP_FROM_CITY:String = "";
		public var SHIP_FROM_STATE:String = "";
		public var SHIP_FROM_COUNTRY:String = "";
		public var SHIP_FROM_POSTAL_CODE:String = "";
		public var SHIP_FROM_NAME:String = "";
		public var SHIP_FROM_ATTENTION_TO:String = "";
		public var SHIP_FROM_EMAIL_ADDRESS:String = "";
		public var SHIP_FROM_PHONE_NUM:String = "";
		public var SHIP_FROM_FAX_NUM:String = "";		
		public var SCHEDULED_ARRIVE_DATE:String = DateManager.GetTodayString();
		public var ACTUAL_ARRIVE_DATE:String = DateManager.GetTodayString();
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var RECV_DOCK:String = "";
		public var CREATE_DATE:String = DateManager.GetTodayString();
		public var START_CHECKIN_DATE:String = DateManager.GetTodayString();
		public var END_CHECKIN_DATE:String = DateManager.GetTodayString();
		
		public function ReceiptHeaderDO():void
		{
		}

		public function Init(xmlObj:XML):void
		{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<RECEIPT_HEADER>
					<INTERNAL_RECEIPT_NUM>{INTERNAL_RECEIPT_NUM}</INTERNAL_RECEIPT_NUM>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<COMPANY>{COMPANY}</COMPANY>
					<RECEIPT_ID>{RECEIPT_ID}</RECEIPT_ID>
					<RECEIPT_TYPE>{RECEIPT_TYPE}</RECEIPT_TYPE>
					<CLOSE_DATE>{CLOSE_DATE}</CLOSE_DATE>
					<PRIORITY>{PRIORITY}</PRIORITY>
					<LEADING_STS>{LEADING_STS}</LEADING_STS>
					<TRAILING_STS>{TRAILING_STS}</TRAILING_STS>
					<ERP_ORDER_ID>{ERP_ORDER_ID}</ERP_ORDER_ID>
					<SHIP_FROM>{SHIP_FROM}</SHIP_FROM>
					<SHIP_FROM_ADDRESS1>{SHIP_FROM_ADDRESS1}</SHIP_FROM_ADDRESS1>
					<SHIP_FROM_ADDRESS2>{SHIP_FROM_ADDRESS2}</SHIP_FROM_ADDRESS2>
					<SHIP_FROM_CITY>{SHIP_FROM_CITY}</SHIP_FROM_CITY>
					<SHIP_FROM_STATE>{SHIP_FROM_STATE}</SHIP_FROM_STATE>
					<SHIP_FROM_COUNTRY>{SHIP_FROM_COUNTRY}</SHIP_FROM_COUNTRY>
					<SHIP_FROM_POSTAL_CODE>{SHIP_FROM_POSTAL_CODE}</SHIP_FROM_POSTAL_CODE>
					<SHIP_FROM_NAME>{SHIP_FROM_NAME}</SHIP_FROM_NAME>
					<SHIP_FROM_ATTENTION_TO>{SHIP_FROM_ATTENTION_TO}</SHIP_FROM_ATTENTION_TO>
					<SHIP_FROM_EMAIL_ADDRESS>{SHIP_FROM_EMAIL_ADDRESS}</SHIP_FROM_EMAIL_ADDRESS>
					<SHIP_FROM_PHONE_NUM>{SHIP_FROM_PHONE_NUM}</SHIP_FROM_PHONE_NUM>
					<SHIP_FROM_FAX_NUM>{SHIP_FROM_FAX_NUM}</SHIP_FROM_FAX_NUM>
					<RECV_DOCK>{RECV_DOCK}</RECV_DOCK>
					<SCHEDULED_ARRIVE_DATE>{SCHEDULED_ARRIVE_DATE}</SCHEDULED_ARRIVE_DATE>
					<ACTUAL_ARRIVE_DATE>{ACTUAL_ARRIVE_DATE}</ACTUAL_ARRIVE_DATE>
					<CREATE_DATE>{CREATE_DATE}</CREATE_DATE>
					<START_CHECKIN_DATE>{START_CHECKIN_DATE}</START_CHECKIN_DATE>
					<END_CHECKIN_DATE>{END_CHECKIN_DATE}</END_CHECKIN_DATE>
				</RECEIPT_HEADER>;
			return xmlObj;
		}
		
		public static function getReceiptHeaders(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var recHdr:ReceiptHeaderDO = new ReceiptHeaderDO();
				recHdr.Init(xml);
				ac.addItem(recHdr);
			}
			return ac;
		}						
	}
}